class Stack: 
	def __init__(self): 
	    self.items = [] 
	
	def isEmpty(self): 
	    return self.items == [] 
	
	def push(self, item): 
	    self.items.append(item) 
		
	def pop(self): 
		return self.items.pop() 
		
	def peek(self): 
		return self.items[-1] 
		
	def size(self): 
		return len(self.items)

def isMatch(expression): # DO NOT modify this line 
    opens = "([{<"
    closers = ")]}>"
    quotes = "\"'`"
    s = Stack() 
    balanced = True 
    index = 0 
    while index < len(expression) and balanced: 
        symbol = expression[index] 
        if symbol in opens: 
            s.push(symbol) 
        elif symbol in closers: 
            if s.isEmpty(): 
                balanced = False 
            else: 
                top = s.pop() 
                if top not in opens or opens.index(top) != closers.index(symbol): 
                    balanced = False 
        elif symbol in quotes:
            if s.isEmpty():
                s.push(symbol)
            else:
                top = s.peek()
                if top == symbol:
                    s.pop()
                else:
                    s.push(symbol)
        index = index + 1 
    
    if balanced and s.isEmpty(): 
        return True 
    else: 
        return False 


# === DO NOT modify the code below ===
def main():
    s1 = input()
    print(isMatch(s1))
    
if __name__ == '__main__':
    main()